package com.hanhanxiaochong.zhongxiangchuanmei.view.my.act;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hanhanxiaochong.zhongxiangchuanmei.R;
import com.hanhanxiaochong.zhongxiangchuanmei.bean.LSMXBean;
import com.hanhanxiaochong.zhongxiangchuanmei.presenter.my.MyWalletLSMXPresenter;
import com.hanhanxiaochong.zhongxiangchuanmei.util.SharedPreferencesUtil;
import com.hanhanxiaochong.zhongxiangchuanmei.view.base.BaseActivity;
import com.hanhanxiaochong.zhongxiangchuanmei.view.iview.ILSMXView;
import com.hanhanxiaochong.zhongxiangchuanmei.view.my.adapter.MyWalletLSMXAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/6/5.
 * Desc   : 我的钱包 流水明细act
 */

public class MyWalletLSMXActivity extends BaseActivity<MyWalletLSMXPresenter> implements ILSMXView{

    @BindView(R.id.img_left)
    ImageView imgLeft;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.view_bottomline)
    View viewBottomline;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;

    private MyWalletLSMXAdapter walletLSMXAdapter;
    private String token;

    private List<LSMXBean> lsmxBeans = new ArrayList<>();

    @Override
    protected void initView() {
        setContentView(R.layout.activity_mywallet_lsmx);
    }

    @Override
    protected void initPresenter() {
        mPresenter = new MyWalletLSMXPresenter(this);
    }

    @Override
    protected void init() {
        setTopView();
        token = SharedPreferencesUtil.getsInstances(this).getLoginInfo().getToken();
        mPresenter.getLSMX(token);


    }

    private void setTopView() {
        imgLeft.setImageResource(R.mipmap.icon_close_black);
        txtTitle.setText("流水明细");
        viewBottomline.setVisibility(View.VISIBLE);
    }

    @OnClick(R.id.ll_leftview)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void getLSMXList(List<LSMXBean> lsmxBeans) {
        walletLSMXAdapter = new MyWalletLSMXAdapter(mContext, R.layout.item_mywallet_lsmx, lsmxBeans);
        recyclerview.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerview.setAdapter(walletLSMXAdapter);
    }
}
